import { IsNotEmpty, MaxLength, MinLength, Validate } from 'class-validator'
import { isExist } from '../../validator/diyValidator/isExist.validator'

import { Bar, BarSchema } from '../../model/bar.schema'
import { SubBar, subBarSchema } from '../../model/subBar.schema'
export class CreateBarDto {
  @IsNotEmpty({ message: '参数不能为空' })
  @MaxLength(10, { message: '标题不能超过十个字符' })
  @MinLength(3, { message: '不能小于3个字符' })
  @Validate(isExist, [Bar, BarSchema], { message: '该贴吧已存在' })
  barName: string
  @IsNotEmpty({ message: '参数不能为空' })
  description: string
  @IsNotEmpty({ message: '参数不能为空' })
  barLogo: string
  @IsNotEmpty({ message: '参数不能为空' })
  creator: string //创建者的用户id
}

//订阅传参
export class SubType {
  @IsNotEmpty({ message: '参数不能为空' })
  user: string
  @IsNotEmpty({ message: '参数不能为空' })
  @Validate(isExist, [SubBar, subBarSchema], { message: '不能重复关注' })
  bar: string
}
